package cn.ctodb.im.dto;

import cn.ctodb.im.proto.Message;

/**
 * All rights Reserved, Designed By www.ctodb.cn
 *
 * @version V1.0
 * @author: lichaohn@163.com
 * @date: 2018-11-12 16:52
 * @Copyright: 2018 www.ctodb.cn All rights reserved.
 */
public abstract class AbstractMessageDTO<T> extends AbstractDTO<T> {

    private String from = "";
    private String to = "";
    private ToType toType = ToType.USER;
    private long cc = 0;

    protected void fromProtoBaseInfo(Message.BaseInfo baseInfo) {
        setCc(baseInfo.getCc());
        setTo(baseInfo.getTo());
        setFrom(baseInfo.getFrom());
        setToType(ToType.valueOf(baseInfo.getToType().name()));
    }

    protected Message.BaseInfo toProtoBaseInfo() {
        return Message.BaseInfo.newBuilder().setCc(getCc()).setFrom(getFrom()).setTo(getTo()).setToType(Message.ToType.valueOf(getToType().name())).build();
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public ToType getToType() {
        return toType;
    }

    public void setToType(ToType toType) {
        this.toType = toType;
    }

    public long getCc() {
        return cc;
    }

    public void setCc(long cc) {
        this.cc = cc;
    }

    public enum ToType {
        USER, GROUP;
    }

}
